#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

namespace Weazel.Gezel.Simulator.Reference
{
  /// <summary>
  /// Serves as the base class for FsmController and
  /// SequentialControllers
  /// </summary>
  abstract class AbstractController
  {
    /// <summary>
    /// The datapath context which the
    /// controller operates on during
    /// simulation
    /// </summary>
    protected readonly DatapathContext datapathContext;

    protected readonly string name;
    public string Name
    {
      get
      {
        return name;
      }
    }

    /// <summary>
    /// Initializes the AbstractController with the
    /// specified datapath context
    /// </summary>
    /// <param name="datapath"></param>
    public AbstractController(DatapathContext datapath, string name)
    {
      this.datapathContext = datapath;
      this.name = name;
    }

    /// <summary>
    /// Begins the programming of a new control step
    /// of a fsm or sequential controller
    /// </summary>
    /// <param name="p"></param>
    /// <param name="p2"></param>
    internal abstract void ProgramNextstep(int p, Symid p2);

    /// <summary>
    /// Add a signalflowgraph to be executed in the
    /// control step currently being controlled. 
    /// SequenceControllers have only one sfg per
    /// control step whereas fsm's can have zero, one
    /// or more control steps
    /// </summary>
    /// <param name="sfg"></param>
    internal abstract void AddSignalFlowGraph(Symid sfg);

    /// <summary>
    /// Called to reset the simulation state
    /// of the controller during simulation
    /// </summary>
    public abstract void Reset();

    /// <summary>
    /// Select new controlstep and activate
    /// proper signals in the datapath context
    /// during simulation
    /// </summary>
    /// <param name="Cycle">current simulation cycle</param>
    public abstract void RunNextStep(long Cycle);

    /// <summary>
    /// Set the initial state of a fsm type 
    /// controller
    /// </summary>
    /// <param name="v">id of the initial state object</param>
    public virtual void AddInitialState(Symid v)
    {
      throw new NotImplementedException();
    }

    /// <summary>
    /// Add an ordinary state of a fsm type 
    /// controller
    /// </summary>
    /// <param name="v">id of the state object</param>
    public virtual void AddState(Symid v)
    {
      throw new NotImplementedException();
    }

    /// <summary>
    /// Add a transition between two states of a fsm type 
    /// controller
    /// </summary>
    /// <param name="from">id of the origin state</param>
    /// <param name="to">id of the destination state</param>
    public virtual void programTransition(Symid from, Symid to)
    {
      throw new NotImplementedException();
    }
  }
}